// components/playList.js
const appInstance = getApp();
Component({
    
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
      list:[],
      currentindex:0
    },
    lifetimes:{
      ready: function() {
         let list = appInstance.globalData.playList;
         let currentindex = appInstance.globalData.currentIndex;
            // 在组件实例进入页面节点树时执行
            this.setData({
              list ,
              currentindex 
            })
            console.log(this.data.currentindex);
          },
    },

    /**
     * 组件的方法列表
     */
    methods: {
      changePlay(event) {
        // console.log(this.data.list[0].id)
        let musicindex = event.currentTarget.id-1;
        let musicId = this.data.list[musicindex+1].id
        this.triggerEvent('changeplay', {
          musicId,
          musicindex:musicindex+1
        })
      }
    }
})
